<template>
  <router-link :to="Router" class="link">
    <el-card class="article-item" shadow="hover" :body-style="{ padding: '0px' }">
      <div class="article-image-container">
        <img :src="ArticleMessage.cover" alt="" />
      </div>
      <div class="card-body">
        <h5 class="article-title">{{ ArticleMessage.title }}</h5>
        <p class="article-introduce">
          {{ ArticleMessage.introduction }}
        </p>
      </div>

      <span class="article-date"
        ><i class="fa fa-calendar"></i>{{ ArticleMessage.create_time }}</span
      >
      <span class="view-num"
        ><i class="fa fa-tag" aria-hidden="true"></i>{{ ArticleMessage.articletypes.type }}</span
      >

      <div class="tag-container">
        <div v-for="(item, index) in ArticleMessage.tag" :key="index">
          <Tag :tag="item.tag"></Tag>
        </div>
      </div>
    </el-card>
  </router-link>
</template>

<script>
import Tag from "@/components/Article/Tag.vue";
export default {
  props: {
    router: { required: true, type: String },
    ArticleMessage: { require: true, type: Object },
    loading: { require: true },
  },
  computed: {
    Router() {
      return "/ShowArticle/" + this.ArticleMessage.id;
    },
  },
  components: {
    Tag,
  },
};
</script>

<style scoped>
.fa-calendar {
  margin-right: 0.3rem;
  line-height: 1rem;
}
.fa-tag {
  margin-right: 0.3rem;
}

.article-image-container img {
  width: 100%;
  height: 15rem;
  object-fit: cover;
}
.card-footer {
  /* display: flex;
  margin: 10px 10px;
  justify-content: space-between; */
  /* position: absolute; */
  overflow: hidden;
}

.article-date {
  position: absolute;
  left: 1rem;
  bottom: 4.5rem;
  line-height: 1rem;
}
.view-num {
  position: absolute;
  right: 1rem;
  bottom: 4.5rem;
}

.card-body {
  margin: 10px;
}
.article-item {
  margin-top: 16px;
  height: 30rem;
  position: relative;
}
.link {
  text-decoration: none;
  transition: 0.5s all;
}
.article-introduce {
  display: -webkit-box;
  overflow: hidden;
  text-overflow: -o-ellipsis-lastline;
  text-overflow: ellipsis;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  /* autoprefixer: off */
  -webkit-box-orient: vertical;
}

.link:hover .article-item {
  animation: ScaleAnimation 0.8s;
  -webkit-animation: ScaleAnimation 0.8s;
}

@keyframes ScaleAnimation {
  0% {
    transform: scale(1, 1);
  }

  50% {
    transform: scale(1.1, 1.1);
  }

  100% {
    transform: scale(1, 1);
  }
}

.tag-container {
  position: absolute;
  bottom: 1rem;
  padding-left: 1rem;
  padding-top: 1rem;
  width: 100%;
  border-top: 2px solid #ddd;
  display: flex;
}
.article-title {
  font-size: 1.5rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin: 0.5rem auto;
  overflow: hidden;
}
</style>
